By default, the TextBoxFor element will have an ID and NAME property that matches the expression property of the element.
@Html.TextBoxFor(model => model.ProductName)
In this example, the ID and NAME would be "ProductName"
If you want to specify an ID or NAME that's different from the expression property, you can use the htmlAttributes overload param.
@Html.TextBoxFor(model => model.ProductName, new { id = "myProduct", name = "myProduct" })
Liked By
Write Answer
How to give the id to the html textbox?
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
25-Sep-2013By default, the TextBoxFor element will have an ID and NAME property that matches the expression property of the element.
@Html.TextBoxFor(model => model.ProductName)
In this example, the ID and NAME would be "ProductName"
If you want to specify an ID or NAME that's different from the expression property, you can use the htmlAttributes overload param.
@Html.TextBoxFor(model => model.ProductName, new { id = "myProduct", name = "myProduct" })